<?php
class BeanUtil {
	public static function fetch($data, $bean){
   		$r = new ReflectionClass($bean);
   		$parr = $r->getProperties();
   		foreach ( $parr as $p ) {
       		if($p->isPublic()){
       			$pname = $p->getName();
       			if(@$data[$pname])
       				$p->setValue($bean, $data[$pname]);
       		}
		}
   	}
}
/*使用方法
             while($data = $mysql->fetch($query)){
   					$bean = new DocBean();
   					BeanUtil::fetch($data, $bean);
   					$arr[$idx++] = $bean;
   				}
 */

?>
